//
//  IndustryViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/20.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "IndustryViewModel.h"
#import "IndustryMoneyPicTableViewCell.h"
#import "IndustryOnePicTableViewCell.h"
#import "IndustryNoPicTableViewCell.h"
#import "IndustryInforModel.h"

@interface IndustryViewModel ()<UITableViewDelegate,UITableViewDataSource>{
    NSMutableArray * cell_ClassArr;
}

@end

@implementation IndustryViewModel

-(instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
//        cell_ClassArr  = [NSMutableArray arrayWithCapacity:0];
//        for (int i=0; i<15; i++) {
//            NSInteger index = arc4random_uniform(2);
//            DLog(@"-     -------            ==       %ld",index);
//            IndustryInforModel * induModel = [IndustryInforModel new];
//            induModel.imageNum = index;
//            [cell_ClassArr addObject:induModel];
//        }
//        tableView.y = tableView.y + kHeightProportion_In_iPhoneTriploid(44);
        tableView.height = tableView.height - kHeightProportion_In_iPhoneTriploid(44);
        tableView.delegate = self;
        tableView.dataSource = self;
        [superView addSubview:tableView];
 
    }
    return self;
}

#pragma mark -- UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    IndustryInforModel * inModel = cell_ClassArr[indexPath.row];
//    if (inModel.imageNum == 0) {
        return kHeightProportion_In_iPhoneTriploid(206);
//    }else if (inModel.imageNum == 1){
//        return kHeightProportion_In_iPhoneTriploid(104);
//    }else{
//        return kHeightProportion_In_iPhoneTriploid(206);
//    }
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BaseTableViewCell * cell;
//    int index = arc4random_uniform(2);
//    DLog(@" -------------    = = == = = = =            %d",index);
//    NSString * classStr = cell_ClassArr[index];
//    if ([classStr isEqualToString:@"IndustryMoneyPicTableViewCell"]) {
//
//        cell = cell_index;
//    }
//    if ([classStr isEqualToString:@"IndustryOnePicTableViewCell"]) {
//        IndustryOnePicTableViewCell * cell_one = [IndustryOnePicTableViewCell cellWithTableView:tableView];
//        cell = cell_one;
//    }
//    if ([classStr isEqualToString:@"IndustryNoPicTableViewCell"]) {
//        IndustryNoPicTableViewCell * cell_No = [IndustryNoPicTableViewCell cellWithTableView:tableView];
//        cell = cell_No;
//    }
    IndustryMoneyPicTableViewCell * cell_index = [IndustryMoneyPicTableViewCell cellWithTableView:tableView];
    cell = cell_index;
    [cell setSepartionLineWith:lineModel_Half];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.delegate && [self.delegate respondsToSelector:@selector(newDidSelectRowAtIndexPath:)]) {
        [self.delegate newDidSelectRowAtIndexPath:indexPath];
    }
}

@end
